package com.book.common.result;

import java.io.Serializable;
import java.util.Map;

/**
 * Description：
 * @Author： leo.xiong
 * @CreateDate： 2020/4/2 14:35
 * @Email： leo.xiong@suyun360.com
 * Version：1.0
 */
public class Success<T> extends RestResponse<T> implements Serializable {
    private static final long serialVersionUID = -1101794948890474158L;

    public Success() {
        super();
        this.result = true;
    }

    public Success(T data) {
        this.data = data;
        this.result = true;
    }

    /**
     * 返回成功信息，但存在提示信息使用
     *
     * @param data
     * @param errorMsg
     */
    public Success(T data, String errorMsg) {
        this.data = data;
        this.errorMsg = errorMsg;
        this.result = true;
    }

    public Success(T data, Map<String, Object> meta) {
        this.data = data;
        this.addMeta(meta);
        this.result = true;
    }

    public static Success buildSuccess(String errorMsg) {
        Success success = new Success();
        success.setErrorMsg(errorMsg);
        return success;
    }
}
